﻿using System;
using System.Runtime.Serialization;

namespace GEPL.Projects
{
    /// <summary>
    /// Represents a console GEPL project
    /// </summary>
    [Serializable]
    internal class ConsoleProject : Project
    {
        /// <summary>
        /// Text output for program
        /// </summary>
        public ConsoleOutput Output { get; set; }

        /// <summary>
        /// Creates an instance of class
        /// </summary>
        /// <param name="output">The "console" used to write text</param>
        public ConsoleProject(ConsoleOutput output)
        {
            Init(output);
        }

        /// <summary>
        /// Deserialization constructor
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        public ConsoleProject(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        /// <summary>
        /// Initializes properties
        /// </summary>
        /// <param name="output"></param>
        public void Init(ConsoleOutput output)
        {
            Output = output;
            SetVariables();
        }

        /// <summary>
        /// Sets variables that can be used from Python code
        /// </summary>
        private void SetVariables()
        {
            Scope.SetVariable("Console", Output);
        }
    }
}